<script src="__PUBLIC__/js/artDialog/jquery.artDialog.js?skin=default"></script>
<script src="__PUBLIC__/js/artDialog/plugins/iframeTools.js"></script>
<style type="text/css">
a.a_upload,a.a_choose{
	border:1px solid #3d810c;
	box-shadow:0 1px #cccccc;
	-moz-box-shadow:0 1px #cccccc;
	-webkit-box-shadow:0 1px #cccccc;
	cursor:pointer; 
	display: inline-block;
	text-align: center;
	vertical-align:bottom;
	overflow:visible;
	border-radius:3px;
	-moz-border-radius:3px;
	-webkit-border-radius:3px;
	vertical-align:middle;
	background-color: #f1f1f1;
	background-image: -webkit-linear-gradient(bottom, #ccc 0%, #e5e5e5 3%, #fff 97%, #fff 100%);
	background-image: -moz-linear-gradient(bottom, #ccc 0%, #e5e5e5 3%, #fff 97%, #fff 100%);
	background-image: -ms-linear-gradient(bottom, #ccc 0%, #e5e5e5 3%, #fff 97%, #fff 100%);
	color: #000;
	border:1px solid #aaa;
	padding:2px 8px 2px 8px;
	text-shadow: 0 1px #ffffff;
	font-size: 14px;
	line-height: 1.5;
}

.cmbitem {
	width: 100px;
	text-align: center;
}
.optsitem {
	float: right;
	margin-right: 50px;
}
.poptvalue {
	width:20px;
	text-align:center;
}
</style>
<div class="pd-20">
    <form action="" method="post" class="form form-horizontal" action="{:U("Admin/Order/addCollocation")}">
    	<input type="hidden" value="{$cid}" id="cid" name="cid">
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>套餐名</label>
            <div class="col-6">
	            	<input type="text" class="input-text" value="{$colname}" id="cname" name="cname" datatype="*2-16" <if condition="$colname neq null">disabled="disabled"</if>>
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>套餐分值</label>
            <div class="col-6">
	            <input type="text" class="input-text" id="tCredit" name="tCredit" <if condition="$colname neq null">value="{$colcredit}"<else/>value="7"</if> datatype="*2-16">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>选择菜品</label>
            <div class="col-6">
	            <ul id='foods'>
	            <volist name="foods" id="food" key="k">
	            	<li>
	            		<span class="cbmitem" name="{$food.name}">
	            			<input class="cbmitem-input" type="checkbox" name="foods[{$food.foodid}]" value="{$food.foodid}" data="{$food.foodid}" <if condition="$ofoods[$food['foodid']] neq null">checked="checked"</if>>{$food.name}:
	            		</span>
	            		<input type="hidden" name="foods[{$food.foodid}][isChs]" <if condition="$ofoods[$food['foodid']] neq null">value="1"<else/>value="0"</if> >
	            		<input type="hidden" name="foods[{$food.foodid}][name]" value="{$food.name}">
	            		<span class="optsitem" name="{$food.name}-opt">
	            			<label class="poptitem">默选<input type="checkbox" name="foods[{$food.foodid}][defChs]" <if condition="$ofoods[$food['foodid']] neq null"><if condition="$ofoods[$food['foodid']]['defchs'] eq 1">checked="checked" value="1"<else/>value="0"</if><else/>checked="checked" value="1" disabled="false"</if>>&nbsp;&nbsp;</label>
	            			<label class="poptitem">必选<input type="checkbox" name="foods[{$food.foodid}][reqChs]" value="1" <if condition="$ofoods[$food['foodid']] neq null"><if condition="$ofoods[$food['foodid']]['reqchs'] eq 1">checked="checked" value="1"<else/>value="0"</if><else/>disabled="false" value="1"</if>>&nbsp;&nbsp;</label>
	            			<label class="poptitem">分值<input type="text" name="foods[{$food.foodid}][cicredit]" <if condition="$ofoods[$food['foodid']] neq null">value="{$ofoods[$food['foodid']]['credit']}"<else/>value="{$food.credit}"</if> class="poptvalue" <if condition="$ofoods[$food['foodid']] eq null">disabled="disabled"</if>></label>
	            		</span>
	            	</li>
	            </volist>
	            </ul>
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input name="fomr-add" class="btn btn-success " type="submit" value="&nbsp;提交&nbsp;">
            </div>
        </div>
    </form>
</div>
<script>
// 适配3.2
var site_url = '{:U("Admin/Upyun/upload", array(), false)}';
//用户-编辑
function manage_edit(title, url, id, w, h, pc) {
	var height = 440 + (h-1)*31;
	if(pc == null) {
		height -= 31;
	}
    layer_show(title, url, w, height);
}

function changesort(obj) {
	//window.location.href="/index.php?g=Admin&m=Order&a=showAll&state="+$(obj).val();
	var sortid = $(obj).val();
	$('#sid').val(sortid);
}

function changeCbpName(obj) {
	var cbpid = $(obj).val();
	$('#cpname').val(cbpid);
	var sel = $('#collocations-sel');
	// 清楚sel中的选项
	sel.empty();
	
	$.ajax({
		url: '{:U("Admin/Order/getOneCollocations")}',
		type: 'POST',
		asyn:true,
		data:{
			combopackid:cbpid
		},
		timeout: 10000,
		dataType:'json',
		success:function(data, textStatus, jsqXHR) {
			var collocations = eval(data);
			for(var i=0;i<collocations.length;i++) {
				sel.append('<option value="'+collocations[i]+'">'+collocations[i]+'</option>');
			}
			$('#colname').val(collocations[0]);
			
		},
		error:function(data, textStatus) {
			alert("获取搭配组数据出错！");
		},
		
	});
}

function changeColName(obj) {
	var colname = $(obj).val();
	$('#colname').val(colname);
}
$(document).ready(function(){
	$('.cbmitem-input').each(function(){
		$(this).change(function(){
			var foodCheckStatus = $(this).is(':checked');
			if(foodCheckStatus == true) {
				$(this).parent().parent().children('.optsitem').find('input').removeAttr('disabled');
				$(this).parent().next().val(1);
			} else {
				$(this).parent().parent().children('.optsitem').find('input').attr('disabled', 'false');
				$(this).parent().next().val(0);
			}
		});
	});
});
</script>